home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Test / TestFunc / Main.C < prev    next >
C/C++ Source or Header  |  1996-06-25  |  1KB  |  55 lines

  1.  
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <ctype.h>
  6.  
  7. #include <exec/exec.h>
  8. #include <exec/memory.h>
  9. #include <exec/types.h>
  10.  
  11. void __asm __saveds strNcpy(register __a0 UBYTE *dest,register __a1 UBYTE *source,register __d0 int chars)
  12. {
  13.   int count=0;
  14.  
  15.   while ((dest[count]=source[count]) && count<chars-1) count++;
  16.   dest[count+1]=0;
  17. }
  18.  
  19. short __asm __saveds position(register __a0 char *substr,register __a1 char *str)
  20. {
  21.   // returns an character offset of a substring in a string
  22.   // this version is CASE SENSITIVE
  23.   // returns -1 if substring not found in the string
  24.  
  25.   char *whstr;
  26.   return((short)((whstr=strstr(str,substr)) ? (short)((LONG)whstr-(LONG)str) : -1));
  27. }
  28.  
  29. void cleartags( char*filenames)
  30. {
  31.   char filename[512];
  32.   int where;
  33.   while (filenames[0]) // any chars left ?
  34.   {
  35.     while ((filenames[0]==' ') && (filenames[0])) filenames++; //skip spaces..
  36.  
  37.     if (filenames[0])
  38.     {
  39.       if (where=position(" ",filenames))
  40.       {
  41.         strNcpy(filename,filenames,where);
  42.         puts(filename);
  43.         filenames+=where;
  44.       }
  45.     }
  46.   }
  47.  
  48. }
  49.  
  50.  
  51. void main(int argc,char *argv[])
  52. {
  53.   cleartags("  banana banana2 ");
  54. }
  55.